package com.chengyu.core.service.recommendGoods.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.chengyu.core.domain.CommonConstant;
import com.chengyu.core.domain.enums.GoodsEnums;
import com.chengyu.core.domain.enums.RedisEnums;
import com.chengyu.core.domain.form.GoodsDtoForm;
import com.chengyu.core.domain.form.GoodsImportForm;
import com.chengyu.core.domain.form.GoodsPublishForm;
import com.chengyu.core.domain.form.GoodsSearchForm;
import com.chengyu.core.domain.result.*;
import com.chengyu.core.exception.ServiceException;
import com.chengyu.core.mapper.*;
import com.chengyu.core.model.*;
import com.chengyu.core.service.goods.GoodsCateService;
import com.chengyu.core.service.goods.GoodsService;
import com.chengyu.core.service.recommendGoods.RecommendGoodsService;
import com.chengyu.core.service.shop.ShopCateService;
import com.chengyu.core.util.RedisUtil;
import com.chengyu.core.util.ValidateUtil;
import com.chengyu.core.utils.StringUtils;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author LeGreen
 * @title 推荐商品管理
 * @date 2022/4/28
 */
@Service
public class RecommendGoodsServiceImpl implements RecommendGoodsService {

    @Autowired
    private RecommendGoodsMapper recommendGoodsMapper;


    @Override
    public Boolean checkIsRecommendGoods(Integer goodsId) {
        RecommendGoodsExample example = new RecommendGoodsExample();
        example.createCriteria().andGoodsIdEqualTo(goodsId);
        List<RecommendGoods> recommendGoodsList = recommendGoodsMapper.selectByExample(example);
        if (recommendGoodsList.size() > 0) {
            return true;
        } else {
            return false;
        }
    }


}